package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.model.Order;
import com.jx.service.OrderService;
import com.jx.servicrimpl.OrderServiceImpl;
/**
 * 增加订单
 * @author 鄢泽然
 *
 */
public class AddOrderController extends HttpServlet {
	OrderService os = new OrderServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}

@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		String time = req.getParameter("time");	//下单时间
		String name = req.getParameter("name");
		String pass = req.getParameter("pass");
		String address = req.getParameter("address");
		String pay = req.getParameter("pay");
		int isok = Integer.parseInt(req.getParameter("isok"));
		String finishtime = req.getParameter("finishtime");
		Order o =  new Order();
		int uid = 1;//用户id
		o.setOtime(time);
		o.setOname(name);
		o.setOpass(pass);
		o.setOaddress(address);
		o.setOpay(pay);
		o.setOisok(isok);
		o.setOfinishtime(finishtime);
		int i = os.addOrder(o, uid);
		PrintWriter pw = resp.getWriter();
		pw.write(String.valueOf(i));
		pw.flush();
		pw.close();
	}
}
